package ti.ml.car.domain;

import java.util.LinkedList;
import java.util.Observable;
import java.util.Queue;

/**
 *
 * @author robin
 */
public class Controller extends Observable {

    private static Controller instance;
    private Queue<String> logs;
    private int counter = 0;

    public static Controller getIntance() {
        if (instance == null) {
            instance = new Controller();
        }
        return instance;
    }

    public Controller() {
        logs = new LinkedList<String>();
    }

    public void appendTxtLog(String txt) {

        logs.offer("\nLog " + counter + ": " + txt);
        counter++;
        setChanged();
        notifyObservers("appendLog");
    }

    public String offerTxtLog() {
        return logs.poll();
    }

    public void endOfRoute(String txt) {
        logs.offer(txt);
        setChanged();
        notifyObservers("endOfRoute");
    }
}
